import 'dart:io';

import 'package:flutter/material.dart';
import 'package:xim/common/get_style_view.dart';
import 'package:xim/config/route_config.dart';
import 'package:xim/screen/profile_screen/profile_screen_controller.dart';
import 'package:xim/screen/profile_screen/profile_screen_style.dart';
import 'package:xim/widget/common/ui/sheet.dart';

class ProfileScreen extends GetStyleControllerView<dynamic, ProfileScreenController, ProfileScreenStyle>{

  ProfileScreen({super.key});

  List<Menu> menus(BuildContext context) => [
    Menu(Icons.settings_outlined, "设置"),
    Menu(Icons.login, "登录设置",onTab: Routers.toLoginSettingPage),
    Menu(Icons.question_mark_outlined, "问题反馈"),
    Menu(Icons.control_camera, "监控", onTab: Routers.toControlPage),
    Menu(Icons.info_outline, "关于"),
    Menu(Icons.power_settings_new_outlined, "退出", onTab: (){
      quitBottomSheet(context);
    } ),
  ];

  quitBottomSheet(BuildContext context){
    selectedBottomSheet(
      context,[("退出登录", 1), ("关闭应用",2)],
      showCancelItem: true,
      getItem: (e)=>e.$1, selectedCallBack: (selectedItem) {
        switch(selectedItem.$2){
          case 1:
            // 退出账号 - 清空缓存数据
            Routers.toWelcomeLoginPage(type: RouteType.replaceAll);
            break;
          case 2:
            // 退出程序
            exit(0);
        }
    },);
  }

  @override
  Widget buildView(BuildContext context, data) {
    initModelColor(context);
    return Scaffold(
      body: Container(
      color: style.bgColor.color,
      child: Column(
          children: [
            Container(
              height: 220,
              width: double.infinity,
              color: style.fgColor.color,
              padding: const EdgeInsets.symmetric(horizontal: 16),
              child: style.userHeader(controller.userInfo),
            ),
            const SizedBox(height: 6,),
            Column(
              children: [
                 SizedBox(height: style.menuVerticalPadding,),
                ...style.menuItems(menus(context), gap: style.menuVerticalPadding),
                 SizedBox(height: style.menuVerticalPadding,),
              ],
            )
          ],
        ),
      ),
    );
  }

}

